package com.zxbit.flash.presenter;

import com.zxbit.flash.BuildConfig;
import com.zxbit.flash.base.BasePresenter;
import com.zxbit.flash.common.UserInfo;
import com.zxbit.flash.mvpview.UpdateVersionMvpView;
import com.zxbit.flash.network.CustomConsumer;
import com.zxbit.flash.network.ParamsFactory;
import com.zxbit.flash.response.UpdateResponse;

import io.reactivex.functions.Consumer;

public class UpdateVersionPresenter extends BasePresenter {
    private UpdateVersionMvpView mvpView;

    public UpdateVersionPresenter(UpdateVersionMvpView mvpView) {
        this.mvpView = mvpView;
    }

    /**
     * 检查google更新的
     */
    public void checkGooglePlayUpdate() {
        toSubScribe(req.getGooglePlayUpdateInfo(BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(null)), new CustomConsumer<UpdateResponse>() {
            @Override
            public void call(UpdateResponse updateResponse) {
                mvpView.onGetDataNext(updateResponse);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                mvpView.onGetDataError(throwable);
            }
        });
    }
}
